using System;

namespace WegasManagementSystem.Models
{
    /// <summary>
    /// 工资项目实体类
    /// </summary>
    public class SalaryItem
    {
        /// <summary>
        /// 工资项ID
        /// </summary>
        public int ItemId { get; set; }

        /// <summary>
        /// 工资项名称
        /// </summary>
        public string ItemName { get; set; }

        /// <summary>
        /// 类型(income:收入项, deduction:扣款项)
        /// </summary>
        public string ItemType { get; set; }

        /// <summary>
        /// 计算公式
        /// </summary>
        public string CalculationFormula { get; set; }

        /// <summary>
        /// 计算公式(与CalculationFormula相同)
        /// </summary>
        public string Formula 
        { 
            get { return CalculationFormula; }
            set { CalculationFormula = value; }
        }

        /// <summary>
        /// 描述
        /// </summary>
        public string Description { get; set; }

        /// <summary>
        /// 是否启用
        /// </summary>
        public int IsActive
        {
            get { return _isActive ? 1 : 0; }
            set { _isActive = value == 1; }
        }

        private bool _isActive;

        /// <summary>
        /// 显示顺序
        /// </summary>
        public int DisplayOrder { get; set; }

        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime CreatedTime { get; set; }

        /// <summary>
        /// 更新时间
        /// </summary>
        public DateTime UpdatedTime { get; set; }

        /// <summary>
        /// 项目类型中文名称（非数据库字段）
        /// </summary>
        public string ItemTypeName
        {
            get
            {
                switch (ItemType)
                {
                    case "income":
                        return "收入项";
                    case "deduction":
                        return "扣款项";
                    default:
                        return ItemType;
                }
            }
        }

        /// <summary>
        /// 默认构造函数
        /// </summary>
        public SalaryItem()
        {
            _isActive = true;
            DisplayOrder = 0;
            CreatedTime = DateTime.Now;
            UpdatedTime = DateTime.Now;
        }
    }
} 